package MealProduct

import (
	"APi/client"
	"APi/request"
	"APi/response"
	"github.com/gin-gonic/gin"
	mealProduct "meal_products_srv/proto"
)

func ListMealProduct(c *gin.Context) {
	userId := c.GetUint("userId")
	var data request.ListMealProductRequest
	if err := c.ShouldBind(&data); err != nil {
		response.CurrencyErrResponse(c, 101, err.Error())
		return
	}
	res, err := client.MealProductList(c, &mealProduct.MealProductListRequest{
		Classification: data.Classification,
		Userid:         int64(userId),
	})
	if err != nil {
		response.CurrencyErrResponse(c, -1, err.Error())
		return
	}
	response.CurrencySuccessResponse(c, "餐品展示成功", map[string]interface{}{"meal_product_list": res.AllMealProduct})
}
